package com.bocom.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;

import com.bocom.bean.User;
import com.bocom.service.*;
import com.sun.org.apache.xpath.internal.operations.Mod;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.servlet.ModelAndView;

@Controller
@SessionAttributes("User")
public class Usercontroller {
	
	@Resource
	private UserService service;
	
	@Resource
	HttpServletRequest request;
	
	@RequestMapping("Login2.do")
	public ModelAndView toLoginPage(){
		return new ModelAndView("/WEB-INF/jsp/login.jsp");
	}
	
	@RequestMapping("Login.do")
	public ModelAndView doLogin(){
		
		String loginPageUrl ="/WEB-INF/jsp/login.jsp";
		String successPageUrl ="/WEB-INF/jsp/success.jsp";
		
		String username = request.getParameter("username");
		String password = request.getParameter("password");
		
		return  service.doLogin(loginPageUrl,successPageUrl,username,password);
	}


	
}
